package com.kaiqingsun.io;

import java.io.*;

public class Demo11 {
//    public static void main(String[] args) throws Exception {
//        try (OutputStream os = new FileOutputStream("./world.txt")) {
//            try (Writer writer = new OutputStreamWriter(os, "UTF-8")) {
//                writer.write("你好中国\r\n");
//                writer.write("没什么");
//            }
//        }
//    }

    public static void main(String[] args) throws Exception {
        try (OutputStream os = new FileOutputStream("./world.txt")) {
            try (Writer writer = new OutputStreamWriter(os, "UTF-8")) {
                try (PrintWriter printWriter = new PrintWriter(writer)) {
                    printWriter.println(1 + 1);
                    printWriter.println(3);
                    printWriter.printf("%s + %d", "我", 3);

                    printWriter.flush();
                }
            }
        }
    }
}
